package com.sms.controller;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.sms.common.A;
import com.sms.pojo.Users;
import com.sms.service.impl.UsersServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
//用户信息修改
@WebServlet("/UsersModify")
public class UsersModifyController extends HttpServlet {

    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException {

        ServletInputStream inputStream = req.getInputStream();
        String s = IoUtil.readUtf8(inputStream);
        JSONObject obj = JSONUtil.parseObj(s);
        Users m=new Users();
        BeanUtil.copyProperties(obj,m);
        UsersServiceImpl service=new UsersServiceImpl();
        service.updateById(m);
        service.getSqlSession().close();
        resp.getWriter().write(JSONUtil.toJsonStr(A.success("修改成功")));

    }
}
